#include "xmppcore/iqparserfactory.h"
#include "xmppcore/iq.h"

namespace yoohoo_xmppcore {

IqParser::IqParser() : _iq(0) {
}

Stanza* IqParser::stanza() {
	if (_iq == 0) {
		_iq = new Iq;
	}

	return _iq;
}

bool IqParser::processText(QString path, QString text) {
	if (path.indexOf('/') != -1)
		return false;

	return true;
}

bool IqParser::setType(QString sType) {
	if ("set" == sType) {
		_iq->setIqType(Iq::IqTypeSet);
	} else if ("get" == sType) {
		_iq->setIqType(Iq::IqTypeGet);
	} else if ("result" == sType) {
		_iq->setIqType(Iq::IqTypeResult);
	} else {
		return false;
	}

	return true;
}

ProtocolKey IqParserFactory::protocolKey() {
	return Iq::PROTOCOL_KEY;
}

XmppParser* IqParserFactory::createParser() {
	return new IqParser;
}

}
